/*
 * File     : Testing.java
 * Created  : 10 Nov 2011
 *
 * Copyright © 2011 Matthew Wilson (mj. {my-surname} .uk {at} gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.dni.internal;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.googlecode.dni.InitialisationOption;
import com.googlecode.dni.type.structure.Padding;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
 * Features exposed only for testing.
 *
 * @author Matthew Wilson
 */
public final class Testing
{

    /** The default padding. */
    // TODO v0.9 Some tests might rely on this having been set by previous tests.  Argh!
    public Padding padding;

    private static final Logger BASE_LOGGER = Logger.getLogger( "" );

    /**
     * Enables test mode.
     */
    @SuppressFBWarnings( value = "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE",
                         justification = "False positive" )
    public static void init()
    {
        String old = System.setProperty( "dni.internal.testing", "true" );
        if ( old == null )
        {
            BASE_LOGGER.setLevel( Level.WARNING );

            System.setProperty( InitialisationOption.ALLOCATOR_DEBUG_MODE.getPropertyName(), "true" );
        }
    }

}
